// // 引入各个路由组件
// import Home from '../pages/home/Home.vue'
// import Search from '../pages/search/Search.vue'
// import Login from '../pages/login/Login.vue'
// import Register from '../pages/register/Register.vue'
// import Detail from '../pages/detail'
// import AddCartSuccess from '../pages/AddCartSuccess'
// import ShopCart from '../pages/ShopCart/ShopCart.vue'
// import Trade from '../pages/trade/Trade.vue'
// import Pay from '../pages/pay/Pay.vue'
// import PaySuccess from '../pages/PaySuccess/PaySuccess.vue'
// import Center from '../pages/center/Center.vue'
// import Myorder from '../pages/center/myoreder/Myorder.vue'
// import Teamorder from '@/pages/center/teamorder/Teamorder.vue'


export default  [
  // 一级路由
  {
    // 主页路由组件
    name:'home',
    path: '/home',
    component: ()=>import('@/pages/home/Home.vue'),
    meta: {
      Isdisplay: true,
      title:"首页"
    },
   
  },
  {
    // 搜索路由组件
    name: 'search',
    path: '/search/:keyword?',
    component: ()=>import('@/pages/search/Search.vue'),
    meta: {
      Isdisplay: true,
      title:"搜索"
    },
    
  },
  {
    // 登录路由组件
    name: 'login',
    path: '/login',
    component: ()=>import('@/pages/login/Login.vue'),
    meta: {
      Isdisplay: false,
      title:"登录"
    },
    
  },
  {
    // 注册路由组件
    name: 'register',
    path: '/register',
    component: ()=>import('@/pages/register/Register.vue'),
    meta: {
      Isdisplay: false,
      title:"注册"
    },
    
  },
  {
    //商品详情路由组件
    name:'detail',
    path:'/detail/:skuId',
    component:()=>import('@/pages/detail'),
    meta: {
      Isdisplay: false,
      title:"详情"
    },
    
  },
  {
    //商品详情路由组件
    name:'addcartsuccess',
    path:'/addcartsuccess/:skuNum',
    component:()=>import('@/pages/AddCartSuccess'),
    meta: {
      Isdisplay: true,
      title:"购物车添加"
    },
    
  },
  {
    // 购物车路由
    name:'shopcart',
    path:'/shopcart',
    component:()=>import('@/pages/ShopCart/ShopCart.vue'),
    meta:{
      Isdisplay:true,
      title:"购物车"
    },
  },
  {
    // 结算路由
    name:'trade',
    path:'/trade',
    component:()=>import('@/pages/trade/Trade.vue'),
    meta:{
      Isdisplay:true,
      title:"结算"
    },
  },
  {
    // 支付路由
    name:'pay',
    path:'/pay',
    component:()=>import('@/pages/pay/Pay.vue'),
    meta:{
      Isdisplay:true,
      title:"支付"
    },
    beforeEnter: (to, from, next) => {
        if (from.path === '/trade') {
          next()
        }else{
          next(false)
        }
    }
  },
  {
    // 支付成功路由
    name:"paysuccess",
    path:'/paysuccess',
    component:()=>import('@/pages/PaySuccess/PaySuccess.vue'),
    meta:{
      Isdisplay:true, 
      title:'支付成功'  
     },
     beforeEnter: (to, from, next) => {
      if (from.path === '/pay') {
        next()
      }else{
        next(false)
      }
  }
  },
  {
    // 个人中心路由
    name:'center',
    path:'/center',
    component:()=>import('@/pages/center/Center.vue'),

     children:[
      // 二级路由
      {
        // name:'myorder',
        path:'myorder',
        component:()=>import('@/pages/center/myoreder/Myorder.vue'),
        meta:{
          Isdisplay:true,
          title:'我的订单'
        }
      },
      {
        // name:'teamorder',
        path:'teamorder',
        component:()=>import('@/pages/center/teamorder/Teamorder.vue'),

        meta:{
          Isdisplay:true,
          title:'团购订单'
        }
      },
      // 路由重定向
      {
        // 重定向到home组件
        path: '/center',
        redirect: '/center/myorder',
      },
    
    ],
    meta:{
      Isdisplay:true,
      title:'个人中心'
    }
  },
  {
    // 重定向到home组件
    path: '/',
    redirect: '/home',
  },

  
]